home *** CD-ROM | disk | FTP | other *** search
- Path: anvil.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: Something about typedef and functions I don't understand
- Date: 1 Mar 1996 15:22:35 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4h80rrINNpoj@anvil.ugrad.cs.ubc.ca>
- References: <4h6924$ihl@pith.uoregon.edu>
- NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
-
- In article <4h6924$ihl@pith.uoregon.edu>,
- Pat O'Connor <pwoc@darkwing.uoregon.edu> wrote:
- >I just ran into a problem using typedef for declaring aliases for function
- >types. Now, I thought that when I say for example,
- > typedef double (*DFunc)(double x);
- >that I could use DFunc to declare (but not define) functions. But.... when
- >I try to compile the following program, the linker has a fit. (granted,
- >the program is pretty stupid - I just wanted to simplify things as much as
- >possible).
- >
- >in file 1 in file 2
- >-------------------------- --------------------------
- >#include <stdio.h> double f(double x) { return x*x;}
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- this is a function
-
- >typedef double (*DFunc)(double x);
- >double DoFunction(DFunc f, double x)
- >{ return f(x); }
- >
- >extern DFunc f;
- ^^^^^^^^^^^^^^^
- this is a pointer to a function, not a function prototype
- --
-
-